package com.ft.turorial.spring.boot.domain;

import java.io.Serializable;
import java.util.Date;

import org.springframework.format.annotation.DateTimeFormat;

import com.ft.turorial.spring.boot.security.vo.UserStatus;


public class User implements Serializable{
	
	private static final long serialVersionUID = -8971505764090290428L;
	private Integer id;
    private String name;
	private Date birthday;
	private String userName;
	private String password;
	private UserStatus status;
	
	private String salt;
    
	public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }
    
    public String getName() {
        return name;
    }

	@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
    public Date getBirthday() {
		return birthday;
	}

	public void setBirthday(Date birthday) {
		this.birthday = birthday;
	}

	public void setName(String name) {
        this.name = name == null ? null : name.trim();
    }

	public String getUserName() {
		return userName;
	}

	public void setUserName(String userName) {
		this.userName = userName;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}
	
	public String getSalt() {
		return salt;
	}

	public void setSalt(String salt) {
		this.salt = salt;
	}

	public String getCredentialsSalt(){
		return salt;
	}

	public UserStatus getStatus() {
		return status;
	}

	public void setStatus(UserStatus status) {
		this.status = status;
	}
	@Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        User user = (User) o;
        
        return (this.id == null ? user.getId() == null : this.id.equals(user.getId()));
    }

    @Override
    public int hashCode() {
        int result = id != null ? id.hashCode() : 0;
        result = 31 * result + (id != null ? id.hashCode() : 0);
        return result;
    }

	@Override
	public String toString() {
		return "User [id=" + id + ", name=" + name + ", birthday=" + birthday + ", userName=" + userName + ", password="
				+ password + ", status=" + status + ", salt=" + salt + "]";
	}
	
}
